export default {
    namespaced: true,
    state: {
        //控制提示框的显示和隐藏
        isShowToast: false,
        //提示文本
        msg: "提示文本",
        type: ""
    },
    mutations: {
        changeIsShowToast(state, payload) {
            state.isShowToast = payload.isShow
            state.msg = payload.msg
            state.type = payload.type
        }
    },
    actions: {
        asyncChangeIsShowToast({ commit }, payload) {
            //先显示
            commit('changeIsShowToast', {
                isShow: true,
                msg: payload.msg,
                type: payload.type
            })

            //再隐藏
            setTimeout(() => {
                commit("changeIsShowToast", {
                    isShow: false,
                    msg: payload.msg,
                    type: payload.type
                })
            }, 1500)
        }
    }
}